home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
source
/
snip9503
/
pluraltx.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-14
|
497b
|
22 lines
/*
** PLURALTX.C - How to print proper plurals
**
** public domain - original algorithm by Bob Stout
*/
#include <stdio.h>
#define plural_text(n) &"s"[(1 == (n))]
#define plural_text2(n) &"es"[(1 == (n)) << 1]
#define plural_text3(n) &"y\0ies"[(1 != (n)) << 1]
main()
{
int i;
for (i = 0; i < 10; ++i)
printf("%d thing%s in %d box%s at %d part%s\n", i, plural_text(i),
i, plural_text2(i), i, plural_text3(i));
return 0;
}